package com.xlf.book.servlet;

import com.xlf.book.biz.BookInfoBiz;
import com.xlf.book.biz.BookTypeBiz;
import com.xlf.book.biz.impl.BookInfoBizImpl;
import com.xlf.book.biz.impl.BookTypeBizImpl;
import com.xlf.book.po.BookInfo;
import com.xlf.book.po.BookType;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * @author xie'lin'feng
 * @date 2020-07-23-14:53
 * @description 查询单个图书处理器
 */
@WebServlet("/queryById")
public class SelectBookInfoServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        Integer id = Integer.valueOf(req.getParameter("id"));
        BookInfoBiz bib = new BookInfoBizImpl();
        BookTypeBiz btb = new BookTypeBizImpl();
        List<BookType> types = btb.queryAll();
        BookInfo info = bib.queryById(id);
        req.setAttribute("typeList",types);
        req.setAttribute("info",info);
        req.getRequestDispatcher("update.jsp").forward(req,resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
